package com.toycloud.system.utils;

import java.util.Comparator;

public class Dictionary {
    public static enum STEP {
        //认知
        RenZhi("认知", "认知阶段-初步印象", "用户对产品的初步认知、印象，如购买渠道等"),
        //吸引
        XiYin("吸引", "吸引阶段-卖点吸引", "产品宣传对用户的吸引程度，用于挖掘钩子卖点"),
        //使用
        ShiYong("使用", "使用阶段-使用后反馈", "用户使用产品的真实反馈，了解产品优劣势，改进产品槽点和提升产品竞争力"),
        //咨询
        ZiXun("咨询", "咨询阶段-购买前咨询", "用户购买前咨询关注点，挖据用户购买驱动关键因素"),
        //用户
        Yonghu("拥护", "拥护阶段-复购、分享、推荐", "挖掘用户复购、分享、推荐的关键因素，提升产品力形成破图效应");
        private final String key;
        private final String cloudName;
        private final String slogan;

        private STEP(final String key,  final String cloudName, final String slogan) {
            this.key = key;
            this.cloudName = cloudName;
            this.slogan = slogan;
        }

        public String key() {
            return key;
        }

        public String cloudName() {
            return cloudName;
        }

        public String slogan() {
            return slogan;
        }

        public static STEP findByKey(String key) {
            for (STEP step : STEP.values()) {
                if (step.key().equals(key)) {
                    return step;
                }
            }
            return null;  // 如果找不到匹配的STEP，返回null
        }
    }


    public static class StepComparator implements Comparator<String> {
        @Override
        public int compare(String key1, String key2) {
            int index1 = STEP.findByKey(key1) != null ? STEP.valueOf(STEP.findByKey(key1).name()).ordinal() : Integer.MAX_VALUE;
            int index2 = STEP.findByKey(key2) != null ? STEP.valueOf(STEP.findByKey(key2).name()).ordinal() : Integer.MAX_VALUE;
            return Integer.compare(index1, index2);
        }
    }

    public static enum USER_ATTITUDE {
        NotSet(0, "未表态"),
        Good(1, "好"),
        Neutral(2, "中"),
        Bad(3, "差");

        private final int value;
        private final String chineseName;

        USER_ATTITUDE(int value, String chineseName) {
            this.value = value;
            this.chineseName = chineseName;
        }

        public int getValue() {
            return value;
        }

        public String getChineseName() {
            return chineseName;
        }

        public static USER_ATTITUDE fromValue(int value) {
            for (USER_ATTITUDE attitude : USER_ATTITUDE.values()) {
                if (attitude.value == value) {
                    return attitude;
                }
            }
            throw new IllegalArgumentException("无效的用户态度值: " + value);
        }

        public static int fromName(String name) {
            for (USER_ATTITUDE attitude : USER_ATTITUDE.values()) {
                if (attitude.getChineseName().equals(name)) {
                    return attitude.value;
                }
            }
            throw new IllegalArgumentException("无效的用户态度名称: " + name);
        }

        @Override
        public String toString() {
            return chineseName;  // 输出中文名称
        }
    }
}
